package client.ui.workform;

import java.io.PrintStream;

import client.core.io.Listner;
import client.core.io.conection.ClientToClient;

public class DialogForm extends javax.swing.JFrame{
	private Listner listner;
	private PrintStream clientToCilent;
	private PrintStream outputStream;
	
	public DialogForm() {
		initComponents();
	}
	public void setStream(PrintStream client){
		this.clientToCilent = client;
	}
	private void initComponents() {

		jScrollPane1 = new javax.swing.JScrollPane();
		jTextAreaShowMessages = new javax.swing.JTextArea();
		jScrollPane2 = new javax.swing.JScrollPane();
		jTextAreaWriteMessages = new javax.swing.JTextArea();
		jButtonSend = new javax.swing.JButton();
		jButtonClose = new javax.swing.JButton();
		jLabelUserName = new javax.swing.JLabel();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		setResizable(false);

		jTextAreaShowMessages.setColumns(20);
		jTextAreaShowMessages.setEditable(false);
		jTextAreaShowMessages.setFont(new java.awt.Font("Times New Roman", 0, 12));
		jTextAreaShowMessages.setRows(5);
		jScrollPane1.setViewportView(jTextAreaShowMessages);

		jTextAreaWriteMessages.setColumns(20);
		jTextAreaWriteMessages.setFont(new java.awt.Font("Times New Roman", 0, 12));
		jTextAreaWriteMessages.setRows(5);
		jScrollPane2.setViewportView(jTextAreaWriteMessages);

		jButtonSend.setText("Send");
		jButtonSend.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButtonSendActionPerformed(evt);
			}
		});

		jButtonClose.setText("Close");
		jButtonClose.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButtonCloseActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						layout.createSequentialGroup()
								.addContainerGap()
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.LEADING)
												.addGroup(
														layout.createSequentialGroup()
																.addGroup(
																		layout.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.LEADING)
																				.addGroup(
																						layout.createSequentialGroup()
																								.addGroup(
																										layout.createParallelGroup(
																												javax.swing.GroupLayout.Alignment.LEADING,
																												false)
																												.addComponent(
																														jScrollPane1,
																														javax.swing.GroupLayout.DEFAULT_SIZE,
																														286,
																														Short.MAX_VALUE)
																												.addComponent(
																														jScrollPane2))
																								.addGap(0,
																										0,
																										Short.MAX_VALUE))
																				.addGroup(
																						layout.createSequentialGroup()
																								.addComponent(
																										jButtonClose,
																										javax.swing.GroupLayout.PREFERRED_SIZE,
																										75,
																										javax.swing.GroupLayout.PREFERRED_SIZE)
																								.addPreferredGap(
																										javax.swing.LayoutStyle.ComponentPlacement.RELATED,
																										javax.swing.GroupLayout.DEFAULT_SIZE,
																										Short.MAX_VALUE)
																								.addComponent(
																										jButtonSend)))
																.addContainerGap())
												.addGroup(
														javax.swing.GroupLayout.Alignment.TRAILING,
														layout.createSequentialGroup()
																.addGap(0,
																		0,
																		Short.MAX_VALUE)
																.addComponent(
																		jLabelUserName,
																		javax.swing.GroupLayout.PREFERRED_SIZE,
																		183,
																		javax.swing.GroupLayout.PREFERRED_SIZE)
																.addGap(59, 59,
																		59)))));
		layout.setVerticalGroup(layout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(
						layout.createSequentialGroup()
								.addGap(4, 4, 4)
								.addComponent(jLabelUserName,
										javax.swing.GroupLayout.PREFERRED_SIZE,
										16,
										javax.swing.GroupLayout.PREFERRED_SIZE)
								.addPreferredGap(
										javax.swing.LayoutStyle.ComponentPlacement.RELATED)
								.addComponent(jScrollPane1,
										javax.swing.GroupLayout.PREFERRED_SIZE,
										176,
										javax.swing.GroupLayout.PREFERRED_SIZE)
								.addPreferredGap(
										javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
								.addComponent(jScrollPane2,
										javax.swing.GroupLayout.PREFERRED_SIZE,
										javax.swing.GroupLayout.DEFAULT_SIZE,
										javax.swing.GroupLayout.PREFERRED_SIZE)
								.addPreferredGap(
										javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
								.addGroup(
										layout.createParallelGroup(
												javax.swing.GroupLayout.Alignment.LEADING)
												.addGroup(
														layout.createSequentialGroup()
																.addComponent(
																		jButtonSend)
																.addGap(0,
																		0,
																		Short.MAX_VALUE))
												.addGroup(
														javax.swing.GroupLayout.Alignment.TRAILING,
														layout.createSequentialGroup()
																.addGap(0,
																		0,
																		Short.MAX_VALUE)
																.addComponent(
																		jButtonClose)
																.addContainerGap()))));

		pack();
	}

	private void jButtonCloseActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButtonCloseActionPerformed

	}

	private void jButtonSendActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButtonSendActionPerformed
		clientToCilent.println(jTextAreaWriteMessages.getText());
		jTextAreaShowMessages.append(jTextAreaWriteMessages.getText());
		jTextAreaWriteMessages.setText("");
	}

	private javax.swing.JButton jButtonClose;
	private javax.swing.JButton jButtonSend;
	private javax.swing.JLabel jLabelUserName;
	private javax.swing.JScrollPane jScrollPane1;
	private javax.swing.JScrollPane jScrollPane2;
	public javax.swing.JTextArea jTextAreaShowMessages;
	private javax.swing.JTextArea jTextAreaWriteMessages;
}
